<?php
namespace app\stores\controller\admin;
use app\BaseController;
use app\common\helper\open\OpenPlatformMiniappHelper;
use app\common\logic\TokenLogic;


class  Miniapp extends BaseController{

    public function qrcodeImg(){
        $shop_id = $this->request->param('shop_id/d');
        $path   = $this->request->param('path');
        $sign   = $this->request->param('sign');
        $t      = $this->request->param('t/d');
        $mysign = md5($shop_id.'|'.$path.'|'.$t.'|'.TokenLogic::getAppQrSignToken());
        if(empty($sign)) die('NO DATA1');
        if($sign != $mysign) die('NO DATA2');
        $OpenPlatformMiniappHelper = new OpenPlatformMiniappHelper();
        $shop_id = 35;
        echo $OpenPlatformMiniappHelper->setShopId($shop_id)->getQrcode($path);
    }
    
    public function getQrcode(){
        $path = $this->request->param('path');
        $path .= '?id='.$this->request->shopId;
        $t = $this->request->time();
        $sign = md5($this->request->shopId.'|'.$path.'|'.$t.'|'. TokenLogic::getAppQrSignToken());
        $url = $this->request->domain().'/stores/miniapp/qrcodeImg?shop_id='.$this->request->shopId.'&t='.$t.'&path='.urlencode($path).'&sign='.$sign;
        return $this->success([
            'img' => $url
        ]);
    }


    
    
} 